package org.dromara.common.translation.core.impl;

import lombok.AllArgsConstructor;
import org.dromara.common.core.service.BusinessConfigCoreService;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.common.translation.core.TranslationInterface;

/**
 * 业务配置翻译实现
 *
 * @author zlj
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.CONFIG_ID_TO_NAME)
public class ConfigNameTranslationImpl implements TranslationInterface<String> {

    private final BusinessConfigCoreService configService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof String ids) {
            return configService.selectNameByIds(ids);
        } else if (key instanceof Long id) {
            return configService.selectNameByIds(id.toString());
        }
        return null;
    }
}
